home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Information / WebSites / Imagine / arexx / twirl.lzx / Twirl.irx
Text File  |  1998-10-01  |  6KB  |  220 lines

  1.  
  2. /*-----------------------------------------------------------------------*/
  3. /* ARexx script for Amiga Imagine 5.0                                    */
  4. /* Creates a planisphere only composed of twirling longitudes            */
  5. /*                                                                       */
  6. /* Author: Anh Tu NGUYEN TRONG                                           */
  7. /* Email: atnt@diaf.fr                                                   */
  8. /*                                                                       */
  9. /* Requirements                                                          */
  10. /* - Workbench 2.04 or higher                                            */
  11. /* - rexxreqtools.library 1.3 or higher                                  */
  12. /* - reqtools.library 38 or higher                                       */
  13. /* - Imagine 5.0                                                         */
  14. /*                                                                       */
  15. /* The rexxreqtools and reqtools libraries can be retrieved from Aminet. */
  16. /* rexxreqtools is an ARexx interface to reqtools.                       */
  17. /*                                                                       */
  18. /* The script can be run without the rexxreqtools library:               */
  19. /* just remove the delimited section. You can edit the source to         */
  20. /* change the parameters.                                                */
  21. /*                                                                       */
  22. /* Warning                                                               */
  23. /* the ARexx script doesn't check the validity of the three numbers.     */
  24. /*                                                                       */
  25. /* Usage                                                                 */
  26. /* - Imagine 5.0 should be already launched                              */
  27. /* - From a Shell window: rx twirl.irx                                   */
  28. /*                                                                       */
  29. /* Three numbers have to be entered through requesters:                  */
  30. /* - radius                 (default value: 100) (must be an even value) */
  31. /* - circle_sections_number (default value: 24)  (must be an even value) */
  32. /* - sections_number        (default value: 12)  (must be an even value) */
  33. /*                                                                       */
  34. /* Note                                                                  */
  35. /* By modifiying the source, you can generate a sphere with the          */
  36. /* half portion filled.                                                  */
  37. /*-----------------------------------------------------------------------*/
  38.  
  39. /*******************************************************************/
  40.  
  41. /* Beginning of twirl.irx */
  42.  
  43.  
  44. /* Sphere's parameters that can be altered manually if the */
  45. /* rexxreqtools library is not used.                       */
  46.  
  47. radius = 100
  48. circle_sections_number = 24
  49. sections_number = 12
  50.  
  51.  
  52. /* --8<-- Start of rexxreqtools part which may be removed ----- */
  53.  
  54. call addlib("rexxreqtools.library", 0, -30, 0)
  55.  
  56.  
  57. radius_box_title = "Radius"
  58. radius_box_message = "Sphere radius ?"
  59.  
  60. circle_sections_box_title = "Circle sections"
  61. circle_sections_box_message = "Number of circle sections ?"
  62.  
  63. vertical_sections_box_title = "Vertical sections"
  64. vertical_sections_box_message = "Number of vertical sections ?"
  65.  
  66. buttons_labels="_OK|_Abort script"
  67.  
  68.  
  69. radius = rtgetlong(radius,,
  70.                    radius_box_message,,
  71.                    radius_box_title,,
  72.                    buttons_labels,,
  73.                    ,,
  74.                    code_retour)
  75.  
  76. if radius == "" then
  77.   exit
  78.  
  79.  
  80. circle_sections_number = rtgetlong(circle_sections_number,,
  81.                                    circle_sections_box_message,,
  82.                                    circle_sections_box_title,,
  83.                                    buttons_labels,,
  84.                                    ,,
  85.                                    code_retour)
  86.  
  87. if circle_sections_number == "" then
  88.   exit
  89.  
  90.  
  91. sections_number = rtgetlong(sections_number,,
  92.                             vertical_sections_box_message,,
  93.                             vertical_sections_box_title,,
  94.                             buttons_labels,,
  95.                             ,,
  96.                             code_retour)
  97.  
  98. if sections_number == "" then
  99.   exit
  100.  
  101. /* --8<-- End of rexxreqtools part which may be removed ----- */
  102.  
  103.  
  104. address "Imagine.1"
  105.  
  106.  
  107. displayrexxptr on
  108.  
  109. detaileditor
  110.  
  111. addsphere radius circle_sections_number sections_number 'OFF'
  112.  
  113. pick select
  114.  
  115.  
  116. /* Number of faces computation */
  117.  
  118. faces_number = ((sections_number - 2) * circle_sections_number * 2) + (2 *
  119. circle_sections_number)
  120.  
  121.  
  122. /* Computation of the number of faces pairs by circumference */
  123.  
  124. pairs_number = circle_sections_number / 2
  125.  
  126.  
  127. facemode
  128. multipickon
  129.  
  130.  
  131. /* Selection of the faces of the first circumference */
  132. /* Particular case because of 2 times less faces     */
  133.  
  134. numero = 1
  135.  
  136. do until numero >= (circle_sections_number + 1)
  137.   pick numero
  138.   numero = numero + 2
  139. end
  140.  
  141.  
  142. /* Faces selection */
  143.  
  144. numero = circle_sections_number + 1
  145. pairs_counter = 0
  146.  
  147. even_increment = 3
  148. odd_increment = 3
  149.  
  150.  
  151. do until (numero >= (faces_number - circle_sections_number))
  152.  
  153.  
  154.  pick numero
  155.  
  156.  numero = numero + 1
  157.  pick numero
  158.  pairs_counter = pairs_counter + 1
  159.  
  160.  
  161.  if (pairs_counter = pairs_number) then
  162.    do
  163.  
  164.      numero = numero + even_increment
  165.      even_increment = even_increment - 1
  166.  
  167.      pairs_counter = 0.5
  168.      pick numero
  169.      numero = numero + 3
  170.    end
  171.  
  172.  else
  173.    do
  174.     if (pairs_counter = (pairs_number - 0.5)) then
  175.       do
  176.         numero = numero + odd_increment
  177.  
  178.         /* Strange but it works !!!*/
  179.         even_increment = odd_increment - 1
  180.  
  181.         pick numero
  182.         pairs_counter = 0
  183.         numero = numero + 2
  184.       end
  185.  
  186.     else
  187.       do
  188.         numero = numero + 3
  189.       end
  190.  
  191.    end
  192.  
  193. end
  194.  
  195.  
  196. /* Selection of the faces of the last circumference */
  197. /* Particular case because of 2 times less faces    */
  198.  
  199. numero = faces_number - circle_sections_number
  200.  
  201. do until numero > faces_number
  202.   pick numero
  203.   numero = numero + 2
  204. end
  205.  
  206.  
  207. /* Deletion of selected faces */
  208. delete
  209.  
  210. multipickoff
  211. objectmode
  212.  
  213. displayrexxptr off
  214. beep
  215.  
  216.  
  217. /* End of twirl.irx */
  218.  
  219. /*******************************************************************/
  220.